#include "Joueur.h"

// Classes
#include "Classe.h"
#include "Barde.h"
#include "Clerc.h"
#include "Druide.h"
#include "Guerrier.h"
#include "Mage.h"
#include "Paladin.h"
#include "Rodeur.h"
#include "Specialiste.h"
#include "Voleur.h"
#include "MetaClasse.h"

// Races
#include "Race.h"
#include "DemiElfe.h"
#include "DemiOgre.h"
#include "DemiOrque.h"
#include "Elfe.h"
#include "Gnome.h"
#include "Hobbit.h"
#include "Humain.h"
#include "Nain.h"
#include "MetaRace.h"

#include <boost/assign/list_of.hpp>

using namespace std;
using namespace boost::assign;

int main(int argc, char* argv[])
{
  FlotMessage dout( ERR );

  if ( argc == 1 )
    {
      dout << "Usage : test_joueur.exe code_race code_classe[s]" << endmsg;
      return 0;
    }

  unsigned int  x(0);
  vector< unsigned int > tab = list_of( 18 )( 17 )( 16 )( 12 )( 10 )( 11 )( 43 );

  vector< string > races = list_of( "Humain" )( "Nain" )( "Elfe" )( "Gnome" )
    ( "Hobbit" )( "Demi-Elfe" )( "Demi-Orque" )( "Demi-Ogre" );

  Race* gars;
  
  string race;
 
  char truc(*argv[1]);
  switch (truc)
    {
    case '1':
      gars = new Humain(x);
      race = "Humain";
      break;
    case '2':
      gars= new Nain(x);
      race = "Nain";
      break;
    case '3':
      gars = new Elfe(x);
      race = "Elfe";
      break;
    case '4':
      gars = new Gnome(x);
      race = "Gnome";
      break;
    case '5':
      gars = new Hobbit(x);
      race = "Hobbit";
      break;
    case '6':
      gars = new DemiElfe(x);
      race = "Demi-Elfe";
      break;
    case '7':
      gars = new DemiOrque(x);
      race = "Demi-Orque";
      break;
    case '8':
      gars = new DemiOgre(x);
      race = "Demi-Ogre";
      break;
    default:
      dout << "Race inconnue" << endmsg;
      return 1;
  }

  gars -> appliquerAjustements(tab);

  dout << DEBUG << "Race OK" << endmsg;

  truc = *argv[2];
  Classe *war;
  switch(truc)
    {
    case '1':
      war = new Guerrier(1, tab, x, race);
      break;
    case '2':
      war = new Paladin(1, tab, x, race);
      break;
    case '3':
      war = new Rodeur(1, tab, x, race);
      break;
    case '4':
      war = new Voleur(1, tab, x, race);
      break;
    case '5':
      war = new Barde(1, tab, x, race);
      break;
    case '6':
      war = new Clerc(1, tab, x, race);
      break;
    case '7':
      war = new Druide(1, tab, x, race);
      break;
    case '8':
      war = new Mage(1, tab, x, race);
      break;
    case '9':
      war = new Specialiste(1, tab, x, race);
      break;
    default:
      dout << ERR << "Classe inconnue" << endmsg;
      return 1;
  }

  dout << DEBUG << "Classe OK" << endmsg;

  //war -> appliquerModif();

  //war -> augmenterTalents(false);
  
  Joueur bob(war, gars, "Swopo");

  bob . setTraits( tab );

  dout << "Joueur OK" << endmsg;

  Classe *war2 = 0;
  if (argc > 3)
    {
      truc = *argv[3];
      switch(truc)
	{
	case '1':
	  war2 = new Guerrier(1, tab, x, race);
	  break;
	case '2':
	  war2 = new Paladin(1, tab, x, race);
	  break;
	case '3':
	  war2 = new Rodeur(1, tab, x, race);
	  break;
	case '4':
	  war2 = new Voleur(1, tab, x, race);
	  break;
	case '5':
	  war2 = new Barde(1, tab, x, race);
	  break;
	case '6':
	  war2 = new Clerc(1, tab, x, race);
	  break;
	case '7':
	  war2 = new Druide(1, tab, x, race);
	  break;
	case '8':
	  war2 = new Mage(1, tab, x, race);
	  break;
	case '9':
	  war2 = new Specialiste(1, tab, x, race);
	  break;
	default:
	  dout << ERR << "Classe inconnue" << endmsg;
	  return 1;
	}

      //war2 -> appliquerModif();
      //war2 -> augmenterTalents(false);

      bob.ajoutClasse(war2);
    }

  dout << INFO << "PPs restants : " << x << endmsg << BLANK;

  bob.setPP(x);
  
  bob.information( dout.stream() );

  bob.determinerDonsDesavantages(Desav);
  bob.determinerDonsDesavantages(Don);  
  bob.determinerCompetences();

  bob.ecrireXml();

  bool sauter( false );

  dout << INFO << war -> nomCompetence(0, sauter) << endmsg;

  delete gars;
  delete war;

  if (argc > 3)
    delete war2;

  return 0;
}
